//聚设计-首页
function jsj_list() {
    /*  let mockData = Mock.mock({
         'list|9': [{
             'img': '@image(388x184, #FFC0CB)',
             'toux': '@image(100x100, #FFC0CB)',
              'name': '@ctitle(2, 4)',
             'desc': '聚衣网设计师',
          }],
     });*/
    new Vue({
        el: "#jsj_list",
        data() {
            return {
                'crumblist': [{
                    'href': '',
                    'text': '首页'
                }, {
                    'href': '',
                    'text': '聚设计'
                }, {
                    'href': '',
                    'text': '设计师列表'
                }],
                list: [],
                pageNo: 1,
                total: 0,
                mark: 1,
                title: "",
                messages: "",
                jsjDesignerInfoUrl: "/jsheji/designer_info_for_user.html",
                jfwPublishDemand: "/jfuwu/xuqiu.html",
            }
        },
        methods: {
            getData() {
                var that = this;
                let pageSize = 12;
                axios.get(urlParam.domain() + '/api/design/designer/list', {
                        params: {
                            pageNo: that.pageNo,
                            pageSize: pageSize,
                            title: that.title,
                        }
                    })
                    .then(function(response) {
                        let pageDate = response.data.data;
                        that.list = pageDate.list;
                        that.total = getPageCount(pageDate.total, pageSize);
                    });

            },
            getPage(page) {
                this.pageNo = page;
                this.getData();

            },
            listen: function(data) {
                // 翻页事件
                alert('当前页码：' + data);
            },
            targetDesigner: function(designerId) {
                setTimeout(window.location = urlParam.location() + this.jsjDesignerInfoUrl + "?id=" + designerId, 0);
            },
            targetPublish: function(designerId) {
                setTimeout(window.location = urlParam.location() + this.jfwPublishDemand + "?designerId=" + designerId, 0);
            }
        },
        created() {
            this.getData();
        }
    });
}

//设计师 个人首页 [设计师角色通道]
function designer_i() {
    let mockData = Mock.mock({
        "top": {
            "topBanner": "@image(960x300,@color)",
            "head": "@image(100x100,@color)",
            "tag|1": ["工作室", "设计师"],
            "name": "@ctitle(4,8)",
            "text": "@ctitle(10,18)",
        },

        "conlist|2-4": [{
            "title": "@ctitle(5,10)",
            "power|1": true, //公开 还是私密 true为公开 false为私密
            "modify": "#", //修改
            "imglist|5-8": [{
                "img": "@image(210x210,@color)",
                "title": "@ctitle(5,10)"
            }]
        }]
    });
    new Vue({
        el: "#designer_i",
        data() {
            return {
                top: "", //顶部
                conlist: [],
                workServerUrl: "/jsheji/designer_add_works.html",
            }
        },
        methods: {
            getData() {
                // this.top = mockData.top; //顶部
                // this.conlist = mockData.conlist; //内容
                let _this = this;
                axios.get(
                    urlParam.domain() + "/api/design/designer/checkDesigner", {
                        params: { token: urlParam.token() }
                    }).then(res => {
                    let designer = res.data.data;
                    let top = {
                            topBanner: designer.bgPicture,
                            head: designer.logo,
                            tag: designer.type == 1 ? "设计师" : "工作室",
                            name: designer.name,
                            text: designer.remarks
                        },
                        conlist = designer.worksList;
                    conlist.forEach(item => {
                        item.pub = item.pub == 1 ? true : false;
                    });
                    _this.top = top;
                    _this.conlist = conlist;
                }).catch(res => {
                    _this.$notify({
                        title: '错误',
                        message: res.error(),
                        type: 'error'
                    })
                })
            },
            targetAddWork(id) {
                if (urlParam.token() == undefined || urlParam.token() == '') {
                    alert('请先登录');
                    return;
                }
                setTimeout(window.location = urlParam.location() + this.workServerUrl, 100);
            },
            clickWorkPub(id) {
                if (urlParam.token() == undefined || urlParam.token() == '') {
                    alert('请先登录');
                    return;
                }
                let _this = this;
                axios({
                    method: "post",
                    headers: { "token": urlParam.token() },
                    url: urlParam.domain() + '/api/design/designerWorks/clickWorkPub',
                    data: { "id": id },
                    transformRequest: [function(data) {
                        let ret = ''
                        for (let it in data) {
                            ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
                        }
                        return ret
                    }],
                }).then(res => {
                    let list = res.data.data;
                    list.forEach(item => {
                        item.pub = item.pub == 1 ? true : false;
                    });
                    _this.conlist = list;
                })
            },
            targetWorkUpdateUrl(id) {
                if (urlParam.token() == undefined || urlParam.token() == '') {
                    alert('请先登录');
                    return;
                }
                setTimeout(window.location = (urlParam.location() + "/jsheji/designer_add_works.html?id=" + id), 100);
            },
        },
        created() {
            this.getData();
        },
        mounted() {

        },
        components: {}
    });
}

//设计师 个人首页 [普通用户角色通道]
function designer_info_for_user() {
    designer_info_for_user = new Vue({
        el: "#designer_i",
        data() {
            return {
                top: "", //顶部
                conlist: [],
                designerId: -1, //设计师id
                jfwPublishDemand: "/jfuwu/xuqiu.html", //聚服务-发布需求页面路径
                concern: false, //当前用户对设计师的关注状态
            }
        },
        methods: {
            getData() {
                let _this = this;
                let designerId = _this.designerId == -1 ? null : _this.designerId;
                console.log("getData time :", designerId);
                axios.get(
                    urlParam.domain() + "/api/design/designer/checkDesigner", {
                        params: {
                            token: urlParam.token(),
                            designerId: designerId
                        }
                    }).then(res => {
                    let designer = res.data.data;
                    if (designer.follow != null) {
                        _this.concern = true;
                    }

                    _this.top = {
                        topBanner: designer.bgPicture,
                        head: designer.logo,
                        tag: designer.type ? "设计师" : "工作室",
                        name: designer.name,
                        text: designer.describe,
                        followId: designer.follow != null ? designer.follow.id : 0,
                    };
                    _this.conlist = designer.worksList;
                    _this.conlist.forEach(item => {
                        item.pub = item.pub == 1 ? true : false;
                        _this.designerId = designer.id;
                    });
                }).catch(res => {
                    _this.$notify({
                        title: '错误',
                        message: res.error(),
                        type: 'error'
                    })
                })
            },
            //"找TA设计" 跳转 聚服务 - 发布需求
            targetPublish: function() {
                setTimeout(window.location = urlParam.location() + this.jfwPublishDemand + "?designerId=" + this.designerId, 0);
            },
            doConcern: function() {
                if (urlParam.token() == undefined || urlParam.token() == '') {
                    alert('请先登录');
                    return;
                }
                let followId = this.top.followId;
                let reqType = this.concern ? "delete" : "add";
                axios({
                    method: "post",
                    url: urlParam.domain() + "/api/design/designerFollow/" + reqType,
                    headers: { "token": urlParam.token() },
                    data: {
                        id: followId,
                        designerId: this.designerId,
                    },
                    transformRequest: [function(data) {
                        let ret = ''
                        for (let it in data) {
                            ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
                        }
                        return ret
                    }]
                }).then(res => {
                    if (reqType == "delete") {
                        this.concern = false;
                    } else {
                        this.concern = true;
                        this.top.followId = res.data.data;
                    }
                }).catch(res => {
                    console.log("doConcern fail!");
                })
            }
        },
        created() {
            let urlparams = globalAPI.getRequest();
            this.designerId = urlparams.id;
            this.getData();
        },
        mounted() {

        },
        components: {}
    });
}

//设计师 工作室 入驻
function designer_join() {
    let mockData = Mock.mock({});
    new Vue({
        el: "#designer_join",
        data() {
            return {
                show: 1, //控制显示 1，个人 2，工作室 默认显示个人
                dialogVisible: false, //添加作品弹窗状态 false true, 默认 false
                //个人 persona
                personalDialogVisible: false, //添加作品弹窗状态 false true, 默认 false
                personalName: "", //姓名
                personalId: "", //身份证号
                personalTel: "", //联系方式
                personalProvinceList: area, //省 传入省市区josn表（数组）
                personalProvinceText: "", //文字
                personalProvinceId: "", //id
                personalProvinceIndex: -1, //数组下标
                personalCityList: [], //市
                personalCityText: "",
                personalCityId: "",
                personalCityIndex: -1,
                personalHeadImg: { //用户头像
                    base64: [""], //这个 preimg. base64才是 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                personalHonorImg: { //荣誉证书 图片
                    base64: [""],
                    url: [""],
                },
                personalWorksImg: { //作品
                    base64: [""],
                    url: [""],
                },
                personalCoverImg: { //封面
                    base64: [""],
                    url: [""],
                },
                personalWork: {
                    name: "",
                    pub: 1, //是否公开  1.公开[默认] 2.否
                    describe: "", //描述
                    type: "",
                    img: []
                }, //作品信息
                personalWorkBtnShow: true, //个人用户 添加作品按钮显示状态 [默认 true , false]
                personalWorkTypeOptions: [], //作品类型
                //工作室 studio
                studioDialogVisible: false, //添加作品弹窗状态 false true, 默认 false
                studioName: "", //姓名
                studioId: "", //身份证号
                studioTel: "", //联系方式
                studioProvinceList: area, //省 传入省市区josn表（数组）
                studioProvinceText: "", //文字
                studioProvinceId: "", //id
                studioProvinceIndex: -1, //数组下标
                studioCityList: [], //市
                studioCityText: "",
                studioCityId: "",
                studioCityIndex: -1,
                studioHeadImg: { //用户头像
                    base64: [""], //这个 preimg.base64 才是 预览图
                    url: [""], //最后ajax提交表单信息时，提交的url路径，这个是单张图片上传完毕后台返回的url路径
                },
                studioHonorImg: { //荣誉证书 图片
                    base64: [""],
                    url: [""],
                },
                studioWorksImg: { //作品
                    base64: [""],
                    url: [""],
                },
                studioCoverImg: { //封面
                    base64: [""],
                    url: [""],
                },
                studioWork: {
                    name: "",
                    pub: 1, //是否公开  1.公开[默认] 2.否
                    describe: "", //描述
                    type: "",
                    img: [""]
                }, //作品信息
                studioWorkBtnShow: true, //工作室 添加作品按钮显示状态 [默认 true , false]
                studioWorkTypeOptions: [],
                worksList: []
            }
        },
        methods: {
            getData() {
                // this.quan = mockData.quan;
                let that = this;
                axios.get(urlParam.domain() + "/api/dict/query", {
                    params: {
                        name: "聚设计-作品类型"
                    }
                }).then(function(response) {
                    that.personalWorkTypeOptions = response.data.data;
                    that.studioWorkTypeOptions = response.data.data;
                })
            },
            //点击标题 切换显示 个人、工作室
            clickShow(index) {
                this.show = index;
            },
            clickWorkPub(index, n) {
                if (index == 1) {
                    this.personalWork.pub = n;
                } else {
                    this.studioWork.pub = n;
                }
            },
            //点击选择 显示下拉框
            clickShowOption(e) {
                e.currentTarget.nextElementSibling.style.display = "block";
            },
            //鼠标移出 关闭下拉框
            closeOption(e) {
                e.currentTarget.getElementsByClassName("option-sub")[0].style.display = "none";
            },
            showWork(index) {
                if (index === 1) {
                    this.personalDialogVisible = true;
                } else {
                    this.studioDialogVisible = true;
                }
            },
            confirmWork(index) {
                if (index == 1) {
                    if (this.personalWork == null) {
                        this.$notify.error({
                            title: "错误",
                            message: '请添加作品信息'
                        })
                    };
                    this.personalWork.img = this.personalWorksImg.url;
                    this.personalDialogVisible = false;
                    this.personalWorkBtnShow = false;
                } else {
                    if (this.studioWork == null) {
                        this.$notify.error({
                            title: "错误",
                            message: '请添加作品信息'
                        })
                    };
                    this.studioWork.img = this.studioWorksImg.url;
                    this.studioDialogVisible = false;
                    this.studioWorkBtnShow = false;
                }
            },
            //个人 ********************************************************
            //点击 省份
            clickPersonalProvince(text, id, index) {
                this.personalProvinceText = text;
                this.personalProvinceId = id;
                this.personalProvinceIndex = index;
                this.personalCityList = area[index].children; //生成 市 选择
                //清空市
                this.personalCityText = "";
                this.personalCityId = "";
                this.personalCityIndex = -1;
            },
            //点击 市区 下拉框
            clickPersonalCity(text, id, index) {
                this.personalCityText = text;
                this.personalCityId = id;
                this.personalCityIndex = index;
            },
            //点击 提交审核 ajax提交
            clickPersonaSubmit(index) {
                var _this = this;
                if (this.personalName == "") {
                    this.$notify.error({
                        title: '错误',
                        message: '姓名不可为空'
                    });
                } else if (this.personalId == "") {
                    this.$notify.error({
                        title: '错误',
                        message: '身份证号不可为空'
                    });
                } else if (this.personalTel == "") {
                    this.$notify.error({
                        title: '错误',
                        message: '联系方式不可为空'
                    });
                } else if (this.personalProvinceId == "" || this.personalCityId == "") {
                    this.$notify.error({
                        title: '错误',
                        message: '请选择所在省市区域'
                    });
                } else if ((index == 1 && this.personalWork == null) ||
                    (this.personalWork.name == "" || this.personalWork.type == "")) {
                    this.$notify.error({
                        title: '错误',
                        message: '请添加作品信息'
                    })
                } else {
                    let designer = {
                        type: index,
                        name: this.personalName,
                        num: this.personalId,
                        mobile: this.personalTel,
                        provinceId: this.personalProvinceId,
                        cityId: this.personalCityId,
                        logo: this.personalHeadImg.url[0],
                        bgPicture: this.personalCoverImg.url[0],
                        worksList: [this.personalWork],
                        certificatePics: [...this.personalHonorImg.url == "" ? [] : this.personalHonorImg.url]
                    }
                    axios({
                            method: 'post',
                            url: urlParam.domain() + '/api/design/designer/add',
                            headers: { "token": urlParam.token(), "Content-Type": "application/json" },
                            data: JSON.stringify(designer)
                        })
                        .then(function(response) {
                            _this.$notify({
                                title: '成功',
                                message: '提交审核成功',
                                type: 'success'
                            });
                            _this.personalProvinceId = "";
                            _this.personalProvinceText = "";
                            _this.personalProvinceIndex = -1;
                            _this.personalCityId = "";
                            _this.personalCityText = "";
                            _this.personalCityIndex = -1;
                            _this.personalName = "";
                            _this.personalId = "";
                            _this.personalTel = "";
                            _this.personalWork = {
                                name: "",
                                pub: 1, //是否公开  1.公开[默认] 2.否
                                describe: "", //描述
                                type: "",
                                img: []
                            };
                            _this.personalWorkBtnShow = true;
                            _this.personalHeadImg = { //荣誉证书 图片
                                base64: [""],
                                url: [""],
                            };
                            _this.personalHonorImg = { //荣誉证书 图片
                                base64: [""],
                                url: [""],
                            };
                            _this.personalWorksImg = { //作品
                                base64: [""],
                                url: [""],
                            };
                            _this.personalCoverImg = { //封面
                                base64: [""],
                                url: [""],
                            };
                        })
                        .catch(function(response) {
                            console.log(response);
                            _this.$notify({
                                title: '错误',
                                message: response.error(),
                                type: 'error'
                            })
                        })
                }
            },
            //工作室 ***************************************************
            //点击 省份
            clickStudioProvince(text, id, index) {
                this.studioProvinceText = text;
                this.studioProvinceId = id;
                this.studioProvinceIndex = index;
                this.studioCityList = area[index].children; //生成 市 选择
                //清空市
                this.studioCityText = "";
                this.studioCityId = "";
                this.studioCityIndex = -1;
            },
            //点击 市区
            clickStudioCity(text, id, index) {
                this.studioCityText = text;
                this.studioCityId = id;
                this.studioCityIndex = index;
            },
            //点击 提交审核 ajax提交
            clickStudioSubmit(index) {
                console.log("工作室提交");
                var _this = this;
                if (this.studioName == null) {
                    this.$notify.error({
                        title: '错误',
                        message: '企业名称不可为空'
                    });
                } else if (this.studioId == null) {
                    this.$notify.error({
                        title: '错误',
                        message: '营业执照代码不可为空'
                    });
                } else if (this.studioTel == "") {
                    this.$notify.error({
                        title: '错误',
                        message: '联系方式不可为空'
                    });
                } else if (this.studioProvinceId == "" || this.studioCityId == "") {
                    this.$notify.error({
                        title: '错误',
                        message: '请选择所在省市区域'
                    });
                } else if ((index == 2 && this.studioWork == null) ||
                    (this.studioWork.name == "" || this.studioWork.type == "")) {
                    this.$notify.error({
                        title: '错误',
                        message: '请添加作品信息'
                    })
                } else {
                    let designer = {
                        type: index,
                        name: this.studioName,
                        num: this.studioId,
                        mobile: this.studioTel,
                        provinceId: this.studioProvinceId,
                        cityId: this.studioCityId,
                        logo: this.studioHeadImg.url[0],
                        bgPicture: this.studioCoverImg.url[0],
                        worksList: [this.studioWork],
                        certificatePics: [...this.studioHonorImg.url == "" ? [] : this.studioHonorImg.url]
                    }
                    axios({
                            method: 'post',
                            headers: { "token": urlParam.token(), "Content-Type": "application/json" },
                            url: urlParam.domain() + '/api/design/designer/add',
                            data: designer,
                        })
                        .then(function(response) {
                            _this.$notify({
                                title: '成功',
                                message: '提交审核成功',
                                type: 'success'
                            });
                            _this.studioProvinceId = "";
                            _this.studioProvinceText = "";
                            _this.studioProvinceIndex = -1;
                            _this.studioCityId = "";
                            _this.studioCityText = "";
                            _this.studioCityIndex = -1;
                            _this.studioName = "";
                            _this.studioId = "";
                            _this.studioTel = "";
                            _this.studioWork = {
                                name: "",
                                pub: 1, //是否公开  1.公开[默认] 2.否
                                describe: "", //描述
                                type: "",
                                img: [""]
                            };
                            _this.studioWorkBtnShow = true;
                            _this.studioHeadImg = { //荣誉证书 图片
                                base64: [""],
                                url: [""],
                            };
                            _this.studioHonorImg = { //荣誉证书 图片
                                base64: [""],
                                url: [""],
                            };
                            _this.studioWorksImg = { //作品
                                base64: [""],
                                url: [""],
                            };
                            _this.studioCoverImg = { //封面
                                base64: [""],
                                url: [""],
                            };
                        })
                        .catch(function(response) {
                            console.log(response);
                            _this.$notify({
                                title: '错误',
                                message: response.error(),
                                type: 'error'
                            })
                        })
                }
            },
        },
        created() {
            this.getData();
        },
        mounted() {

        },
        components: {}
    })
}

//添加作品
function designer_add_works() {
    let mockData = Mock.mock({});
    designer_add_works = new Vue({
        el: "#designer_add_works",
        data() {
            return {
                worksId: -1, //作品id
                worksName: "", //作品名称
                worksText: "", //作品简介
                worksType: "", //类型
                power: 1, //权限 默认为1，是  2为否
                worksbase64: [], //预览图
                worksurl: [], //ajax返回的图片路径
                workstext: [], //描述
                worksImg: {
                    base64: [""],
                    url: [""]
                },
                //提示文字
                dialogVisible: false, //控制 显示、隐藏提示框
                dialogTitle: "", //提示框 标题
                dialogBtnText: "", //提示框 按钮文字
                //设计师作品类型
                workTypeOptions: [],
                //验证项
                testoption: {},
                ajaxurl: "",
                urlReqType: 1 //页面请求类型  默认1 新增 |2 修改
            }
        },
        methods: {
            getData() {
                // this.quan = mockData.quan;
                this.getWorkType();
                if (this.worksId != -1) {
                    let id = this.worksId;
                    this.getWorkDate(id);
                }
            },
            //获取作品类型
            getWorkType() {
                let that = this;
                axios.get(urlParam.domain() + "/api/dict/query", {
                    params: {
                        name: "聚设计-作品类型"
                    }
                }).then(function(response) {
                    that.workTypeOptions = response.data.data;

                })
            },
            //获取作品信息 [仅当从修改入口进入页面时调用]
            getWorkDate(id) {
                axios.get(urlParam.domain() + "/api/design/designerWorks/getWorkDetail", {
                        params: {
                            workId: id
                        },
                        headers: { token: urlParam.token() }
                    })
                    .then(res => {
                        let work = res.data.data;
                        this.worksName = work.name;
                        this.worksText = work.describe;
                        this.worksType = work.type;
                        this.power = work.pub;

                        //数组置空
                        this.worksImg.base64 = [];
                        this.worksImg.url = [];
                        work.imgList.forEach((item, index) => {
                            this.worksImg.base64.push(item.fileUrl);
                            this.worksImg.url.push(item.fileUrl);
                        });
                        this.worksImg.base64.push("");
                        this.worksImg.url.push("");
                    })
                    .catch(res => {
                        console.log(" Req getDetail fail!");
                    })
            },
            //点击选择 显示下拉框
            clickShowOption(e) {
                e.currentTarget.nextElementSibling.style.display = "block";
            },
            //鼠标移出 关闭下拉框
            closeOption(e) {
                e.currentTarget.getElementsByClassName("option-sub")[0].style.display = "none";
            },
            //点击选择 权限
            clickPower(n) {
                this.power = n;
            },
            //点击删除
            clickDel(index) {
                this.worksbase64.splice(index, 1);
                //现在还没有ajax接口，没有返回的url路径
                //this.worksurl.splice(index, 1);
                this.workstext.splice(index, 1);
            },
            //显示提示框 接受josn格式的参数
            //showdialog({title:"",btnText:""})
            showdialog(josn) {
                this.dialogVisible = true; //显示
                this.dialogTitle = josn.title; //标题
                this.dialogBtnText = josn.btnText; //按钮文字
            },
            // //选择图片 添加到 works 数组中
            // chooseImg(e) {
            //     var testoption = this.testoption; //验证项
            //     var that = this; //that指向vue实例
            //     var fileInput = e.currentTarget; //用于 清除input中的文件
            //     //验证失败 清除 input file 里的文件
            //     var failTest = function () {
            //         fileInput.value = "";
            //     };
            //     //验证成功 显示预览图 判断是否增加下一个上传图片input 保存ajax返回的图片路径
            //     var successTest = function (base64) {
            //         fileInput.value = ""; //不管成不成功都删除input里的文件
            //         that.ajaxurl = urlParam.domain()+"/api/upload";
            //         let _base64 = base64;
            //
            //         if (that.ajaxurl) {
            //             //ajax上传单张图片
            //             axios({
            //                 method:"post",
            //                 url:that.ajaxurl,
            //                 data:{"base64": _base64},
            //                 transformRequest: [function (data) {
            //                     let ret = ''
            //                     for (let it in data) {
            //                         ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
            //                     }
            //                     return ret
            //                 }]
            //             }).then(function (res) { //成功上传 返回图片路径
            //                 console.log("that length:"+that.worksbase64.length);
            //                 Vue.set(that.worksbase64, that.worksbase64.length, base64); //保存 显示 预览图
            //                 that.worksurl[that.worksbase64.length] = res.data.data; //保存图片路径
            //                 console.log("that url :"+that.worksurl);
            //                 // console.log(res);
            //             }).catch(function (error) { //上传失败 提示
            //                 that.showdialog({title: "上传失败，可能是网速原因，请再次上传", btnText: "好 的"});
            //             });
            //         } else {
            //             that.worksurl.push("");
            //             that.workstext.push("");
            //             Vue.set(that.worksbase64, that.worksbase64.length, base64); //保存 显示 预览图
            //             console.log("注意，没有ajax上传，现在仅为前端测试");
            //         }
            //     };
            //     //验证图片格式
            //     var imgtype = fileInput.value.split(".");
            //     imgtype = imgtype[imgtype.length - 1]; //获取文件后缀
            //     if (!globalAPI.testImgType(imgtype)) {
            //         this.showdialog({title: "您的文件格式不符", btnText: "好 的"});
            //         failTest();
            //         return;
            //     }
            //     var file = fileInput.files[0]; //得到input file 里的文件对象file
            //     //如果需要验证图片的体积
            //     if (testoption.volume) {
            //         //验证文件大小
            //         var size = file.size; //上传 文件 的大小 单位byte
            //         //图片大小限制为20kb以内
            //         if (size > testoption.volume * 1024) {
            //             this.showdialog({
            //                 title: "您的图片体积为" + (size / 1024).toFixed(2) + "kb，超过" + testoption.volume + "kb限制",
            //                 btnText: "好 的"
            //             });
            //             failTest();
            //             return;
            //         }
            //         ;
            //     }
            //     //获取图片base64码
            //     var reader = new FileReader();
            //     reader.readAsDataURL(file); //传入文件对象file
            //     reader.onload = function (e) { //读取 文件对象file 完成
            //         var base64 = e.target.result; //文件对象file 图片bse64码
            //         //如果不需要验证图片尺寸
            //         if (!(testoption.minwidth || testoption.minheight || testoption.maxwidth || testoption.maxheight || testoption.width || testoption.height)) {
            //             successTest(base64);
            //             return;
            //         }
            //         //创建一个隐藏的 img 标签
            //         document.getElementsByTagName("body")[0].insertAdjacentHTML("beforeend", `<img src="" id="imgsize" style="display:none;">`);
            //         var imgHide = document.getElementById("imgsize"); //隐藏的img标签，用于获取图片尺寸
            //         imgHide.src = base64;
            //         imgHide.onload = function () { //图片加载完成 此隐藏图片用来获取图片尺寸
            //             var width = imgHide.width; //图片宽
            //             var height = imgHide.height; //图片高
            //             console.log(width > testoption.minwidth);
            //             imgHide.remove(); //将创建的隐藏的 img 标签删除
            //             //验证 图片尺寸
            //             //验证 图片最小宽度
            //             if (testoption.minwidth) {
            //                 if (width < testoption.minwidth) { //图片宽度小于最小宽度 验证失败
            //                     that.showdialog({title: "您的图片宽度过小", btnText: "好 的"});
            //                     failTest();
            //                     return;
            //                 }
            //             }
            //             //验证 图片最小高度
            //             if (testoption.minheight) {
            //                 if (height < testoption.minheight) { //图片宽高度小于最小高度 验证失败
            //                     that.showdialog({title: "您的图片高度过小", btnText: "好 的"});
            //                     failTest();
            //                     return;
            //                 }
            //             }
            //             //验证 图片最大宽度
            //             if (testoption.maxwidth) {
            //                 if (width > testoption.maxwidth) { //图片宽度大于最大宽度 验证失败
            //                     that.showdialog({title: "您的图片宽度过大", btnText: "好 的"});
            //                     failTest();
            //                     return;
            //                 }
            //             }
            //             //验证 图片最大高度
            //             if (testoption.maxheight) {
            //                 if (height > testoption.maxheight) { //图片高度大于最大高度 验证失败
            //                     that.showdialog({title: "您的图片高度过大", btnText: "好 的"});
            //                     failTest();
            //                     return;
            //                 }
            //             }
            //             //验证 图片宽度
            //             if (testoption.width) {
            //                 if (width != testoption.width) {
            //                     that.showdialog({title: "您的图片宽度不符", btnText: "好 的"});
            //                     failTest();
            //                     return;
            //                 }
            //             }
            //             //验证 图片高度
            //             if (testoption.height) {
            //                 if (height != testoption.height) {
            //                     that.showdialog({title: "您的图片高度不符", btnText: "好 的"});
            //                     failTest();
            //                     return;
            //                 }
            //             }
            //             //通过验证 显示预览图
            //             successTest(base64);
            //         }
            //     }
            // },

            //点击上传
            clickWorkSubmit() {
                var _this = this;
                if (_this.urlReqType == 1) {
                    console.log("新增作品提交");
                } else {
                    console.log("修改作品提交");
                }
                if (this.worksName == "") {
                    this.$notify.error({
                        title: '错误',
                        message: '作品名称不可为空'
                    });
                } else if (this.worksImg.url.length <= 0) {
                    this.$notify.error({
                        title: '错误',
                        message: '请添加作品图片'
                    });
                } else {
                    let reqUrl = _this.urlReqType == 1 ? urlParam.domain() + '/api/design/designerWorks/add' :
                        urlParam.domain() + '/api/design/designerWorks/update';
                    axios({
                            method: 'post',
                            url: reqUrl,
                            headers: { "token": urlParam.token() },
                            data: {
                                "id": _this.worksId,
                                "name": _this.worksName,
                                "describe": _this.worksText,
                                "type": _this.worksType,
                                "pub": _this.power,
                                "picUrls": [..._this.worksImg.url == "" ? [] : _this.worksImg.url]
                            },
                            transformRequest: [function(data) {
                                let ret = ''
                                for (let it in data) {
                                    ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
                                }
                                return ret
                            }],
                        })
                        .then(function(response) {
                            _this.$notify({
                                title: '成功',
                                message: '提交审核成功',
                                type: 'success'
                            });
                            if (_this.urlReqType == 1) {
                                _this.worksName = "", //作品名称
                                    _this.worksText = "", //作品简介
                                    _this.worksType = "", //类型
                                    _this.power = 1, //权限 默认为1，是  2为否
                                    _this.worksImg = {
                                        base64: [""],
                                        url: [""]
                                    }
                            } else {
                                setTimeout(window.location = urlParam.location() + "/jsheji/designer_i.html", 1000);
                            }
                        })
                        .catch(function(response) {
                            console.log(response);
                            _this.$notify({
                                title: '错误',
                                message: response.error(),
                                type: 'error'
                            })
                        })
                }
            }
        },
        created() {
            let urlparams = globalAPI.getRequest();
            let id = urlparams.id;
            if (id != null && id != '' && id != 'undefined' && id != undefined) {
                this.urlReqType = 2;
                this.worksId = id;
            }
            this.getData();
        },
        mounted() {

        },
        components: {}
    });
}

//设计师详情页
function designer_detail() {
    let mockData = Mock.mock({});
    new Vue({
        el: "#designer_detail",
        data() {
            return {

            }
        },
        methods: {

        },
        created() {

            // this.getData();
        },
        mounted() {

        },
        components: {}
    });
}

//设计师详情页
function designer_join_success() {
    new Vue({
        el: "#designer_join_success",
    });
}